package com.yoogor.xposedtest;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import static org.junit.Assert.*;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getTargetContext();

        assertEquals("com.yoogor.xposedtest", appContext.getPackageName());
        try {
            InputStream input = appContext.getAssets().open("html.html");

            StringBuffer out = new StringBuffer();
            byte[] b = new byte[4096];
            for (int n; (n = input.read(b)) != -1;) {
                out.append(new String(b, 0, n));
            }
            List<MMMessageEntity> mmMessageEntities = JsoupParse.parse(out.toString());
            for (MMMessageEntity mmMessageEntity : mmMessageEntities) {
                Log.e("dsada", mmMessageEntity.getTitle());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
